import {_decorator, Component, resources, TextAsset} from 'cc';
import {CSVParser} from "db://assets/scripts/CSVParser";

const {ccclass, property} = _decorator;

@ccclass('MainController')
export class MainController extends Component {
    start() {
        resources.load("datas/base", TextAsset, (err: Error, data: TextAsset) => {
            if (err) {
                console.log(err);
                return;
            }

            // 解析数据
            let csv = CSVParser.parseToCSV(data.text,3);
            csv.header.forEach(row => {
                console.log(row.join("-"));
            });
            console.log("-------------------------------------------------");
            csv.datas.forEach(row => {
                console.log(row.join("-"));
            });
        });
    }

    update(deltaTime: number) {

    }
}